package com.mikelouis.test.scala.proginscala.chapter21

/**
 * Created by yuazhu on 2/1/2015.
 */
object ImplicitParameterTest2 {
  def main(args: Array[String]) {
    import JoesPrefs._
    Greeter.greet("Joe")(prompt,drink)

    Greeter.greet("Joe2")
  }


  class PreferredPrompt(val preference: String)

  class PreferredDrink(val preference: String)

  object Greeter {
    def greet(name: String)(implicit prompt: PreferredPrompt, drink: PreferredDrink) {
      println("Welcome, " + name + ". The system is ready.")
      print("But while you work, ")
      println("why not enjoy a cup of " + drink.preference + "?")
      println(prompt.preference)
    }
  }

  object JoesPrefs {
    implicit val prompt = new PreferredPrompt("Yes, master> ")
    implicit val drink = new PreferredDrink("tea")
  }

}
